package com.ysd.controller;


import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ysd.entity.Read_room;
import com.ysd.repository.Read_roomRepository;
import com.ysd.util.Result;

@RestController
public class Read_roomController {
	@Autowired
	private Read_roomRepository rrRep;
	@RequestMapping("fandAllRoom")
	public Object findAllroom(){
		List<Read_room> room=rrRep.findAll();
		return room;
	}
	@RequestMapping("updateRoom")
	public Object  updateRoom(String name, Integer id) {
		int i=rrRep.setFixedRoomNameFor(name, id);
		if (i > 0) {
			return Result.toClient("0", "修改成功","");
		} else {
			return Result.toClient("1", "修改失败","");
		}
	}
	@RequestMapping("insertById")
	public Object  insertRoom(String name) {
		int i=rrRep.insertRoom(name);
		if (i > 0) {
			return Result.toClient("0", "添加成功","");
		} else {
			return Result.toClient("1", "添加失败","");
		}
	}
	@RequestMapping("delRoom")
	public Object delectRoom(Integer id){
		int i=rrRep.delectRoomByid(id);
		if (i > 0) {
			return Result.toClient("0", "删除成功","");
		} else {
			return Result.toClient("1", "删除失败","");
		}
	}
}
